// Ordered Logit Models in Stata 
// Using Pew data including 2023 round.

use "Pew2010-2023_VDEM.dta"

gen econ_good = 5 - econ_sit 
gen leftwing = 8 - ideology 
gen baseline = 5- fav_baseline 


gen demsat01 = . 
replace demsat01 = 0 if demsat ==1 
replace demsat01 = 0 if demsat ==2 
replace demsat01 = 1 if demsat ==3 
replace demsat01 = 1 if demsat ==4 

gen post2022 = .
replace post2022 =   1 if year>2021
replace post2022 =   0 if year<2022

gen demsat_post22 = demsat01*post2022



xi:ologit fav_russia demsat01 post demsat_post female education income religion_import leftwing econ_good  age age_square baseline v2x_libdem i.country  i.year [aw=weight]  if year>2016

estimates store o1_new, title(Russia)

xi:ologit fav_china demsat01 post demsat_post female education income religion_import leftwing econ_good  age age_square baseline v2x_libdem i.country  i.year [aw=weight]  if year>2016

estimates store o2_new, title(China)

xi:ologit fav_us demsat01 post demsat_post female education income religion_import leftwing econ_good  age age_square baseline  v2x_libdem i.country  i.year [aw=weight]  if year>2016

estimates store o3_new, title(United States)

xi:ologit fav_eu demsat01 post demsat_post female education income religion_import leftwing econ_good  age age_square baseline  v2x_libdem i.country  i.year [aw=weight]  if year>2016

estimates store o4_new, title(EU)

esttab o1_new o2_new o3_new o4_new using "ologits_new.tex", replace cells(b(star fmt(3)) se(par fmt(2))) 
